package work;

public class work3 {

    public static int abs(int num) {
        int absNum = num < 0 ? -num : num;

        return absNum;

    }

    public static float abs(float num) {
        float absNum = num < 0 ? -num : num;

        return absNum;

    }

    public static double abs(double num) {
        double absNum = num < 0 ? -num : num;

        return absNum;

    }

    public static void main(String[] args) {
        int a = 123;

        float b = -123f;

        double c = -123.456;

        System.out.println("变量a：" + a + " " + "绝对值：" + abs(a));

        System.out.println("变量b：" + b + " " + "绝对值：" + abs(b));

        System.out.println("变量c：" + c + " " + "绝对值：" + abs(c));
    }

}
